#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

vector<int> cows;
vector<vector<int>> g;
vector<int> visited;
vector<int> reachCount;

void dfs(int start, int u) {
    visited[u] = true;
    reachCount[u]++;  // 这个牧场可以被start这头奶牛到达
    
    for(int v : g[u]) {
        if(!visited[v]) {
            dfs(start, v);
        }
    }
}

int main() {
    int k, n, m;
    cin >> k >> n >> m;
    
    cows.resize(k);
    g.resize(n + 1);
    reachCount.resize(n + 1, 0);
    
    for(int i = 0; i < k; i++) {
        cin >> cows[i];
    }
    
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    
    // 对每头奶牛进行DFS
    for(int i = 0; i < k; i++) {
        visited.assign(n + 1, 0);  // 重置访问标记
        dfs(cows[i], cows[i]);
    }
    
    // 统计有多少个牧场被所有k头奶牛到达
    int count = 0;
    for(int i = 1; i <= n; i++) {
        if(reachCount[i] == k) {
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}